<div class="problemindexholder" problemindex="B">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     B. Similar Words
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     2 seconds
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     512 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     Let us call a non-empty sequence of lowercase English letters a
     <span class="tex-font-style-it">
      word
     </span>
     .
     <span class="tex-font-style-it">
      Prefix
     </span>
     of a word
     <span class="tex-span">
      <i>
       x
      </i>
     </span>
     is a word
     <span class="tex-span">
      <i>
       y
      </i>
     </span>
     that can be obtained from
     <span class="tex-span">
      <i>
       x
      </i>
     </span>
     by removing zero or more last letters of
     <span class="tex-span">
      <i>
       x
      </i>
     </span>
     .
    </p>
    <p>
     Let us call two words
     <span class="tex-font-style-it">
      similar
     </span>
     , if one of them can be obtained from the other by removing its first letter.
    </p>
    <p>
     You are given a set
     <span class="tex-span">
      <i>
       S
      </i>
     </span>
     of words. Find the maximal possible size of set of non-empty words
     <span class="tex-span">
      <i>
       X
      </i>
     </span>
     such that they satisfy the following:
    </p>
    <ul>
     <li>
      each word of
      <span class="tex-span">
       <i>
        X
       </i>
      </span>
      is prefix of some word from
      <span class="tex-span">
       <i>
        S
       </i>
      </span>
      ;
     </li>
     <li>
      <span class="tex-span">
       <i>
        X
       </i>
      </span>
      has no similar words.
     </li>
    </ul>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     Input data contains multiple test cases. The first line of the input data contains an integer
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     — the number of test cases. The descriptions of test cases follow.
    </p>
    <p>
     The first line of each description contains an integer
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     — the number of words in the set
     <span class="tex-span">
      <i>
       S
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 10
      <sup class="upper-index">
       6
      </sup>
     </span>
     ). Each of the following
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     lines contains one non-empty word — elements of
     <span class="tex-span">
      <i>
       S
      </i>
     </span>
     . All words in
     <span class="tex-span">
      <i>
       S
      </i>
     </span>
     are different.
    </p>
    <p>
     It is guaranteed that the total length of all words in one input data doesn't exceed
     <span class="tex-span">
      10
      <sup class="upper-index">
       6
      </sup>
     </span>
     .
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     For each test case print one line that contains one integer
     <span class="tex-span">
      <i>
       m
      </i>
     </span>
     — the maximal number of words that
     <span class="tex-span">
      <i>
       X
      </i>
     </span>
     can contain.
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Example
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>2<br/>3<br/>aba<br/>baba<br/>aaab<br/>2<br/>aa<br/>a<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>6<br/>1<br/></pre>
     </div>
    </div>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
